package com.taoyige.bean;

import java.io.Serializable;
import java.net.URLEncoder;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;

import com.sina.weibo.sdk.utils.MD5;

/**
 * 接口URL实体类
 * @author peter
 * @version 1.0
 * @created 2014-11-12
 */
@JsonIgnoreProperties(ignoreUnknown=true)
public class URLs implements Serializable {
	
	public final static String HOST = "api.taoyige.com";
//	public final static String HOST = "192.168.1.109:3001";
	public final static String STATIC_HOST = "http://s.taoyige.com";
//	public final static String STATIC_HOST = "http://192.168.1.200:3001";
	public final static String HTTP = "http://";
	public final static String HTTPS = "https://";
	
	private final static String URL_SPLITTER = "/";
	private final static String URL_UNDERLINE = "_";
	
	private final static String PARAMS_TOKEN="?token=AMC4FRJZVG1T3S5NUHIWX9QKL07BOPY286ED";
	private final static String URL_API_HOST = HTTP + HOST + URL_SPLITTER;
	
	public final static String UPDATE_CLIENT_INFO = URL_API_HOST+"api/app/addDevice"+PARAMS_TOKEN;
	
	public final static String UPDATE_APP_VERSION = URL_API_HOST+"apps/version/android";
	
	public final static String UPDATE_WELCOME_VERSION = URL_API_HOST+"apps/welcome/android";
	
	public final static String GOODS_INDEX= URL_API_HOST+"api/goods/detail"+PARAMS_TOKEN;
	
	public final static String GOODS_COMMING_SOON =  URL_API_HOST+"api/goods/commingsoon"+PARAMS_TOKEN;
	public final static String GOODS_DETAIL = URL_API_HOST+"api/goods/detail"+PARAMS_TOKEN;
	
	public final static String ADDR_DEFAULT= URL_API_HOST+"api/addr/defaultAddr"+PARAMS_TOKEN;
	public final static String ADDR_LIST = URL_API_HOST+"api/addr/list"+PARAMS_TOKEN;
	//public final static String ADDR_LIST = "http://www.etejia.cn/json7.html";
	
	public final static String ADDR_SET_DEFAULT = URL_API_HOST+"api/addr/setDefault"+PARAMS_TOKEN;
	public final static String ADDR_ADD = URL_API_HOST+"api/addr/add"+PARAMS_TOKEN;
	public final static String ADDR_UPDATE = URL_API_HOST+"api/addr/update"+PARAMS_TOKEN;
	public final static String ADDR_DEL = URL_API_HOST+"api/addr/del"+PARAMS_TOKEN;
	
	public final static String GOODS_BUY = URL_API_HOST+"/api/order/checkPurchase"+PARAMS_TOKEN;
	
	/**uid */
	public final static String USER_INFO = URL_API_HOST+"api/user/info"+PARAMS_TOKEN;
	/**
	 * method:POST
	*	@params pid：第三方平台id，支付宝是1、微博是2、QQ是3；pUserID：用户在第三方平台的唯一ID；
	*pUserName：用户在第三方平台上的昵称；userName：用户昵称；thumbUrl：头像地址（可选）
	 */
	public final static String USER_ADD= URL_API_HOST+"api/user/create"+PARAMS_TOKEN;
	
	
	/**
	 * Method: POSTsh  生成订单
	*	@params userID：用户ID；productID：商品ID；amount：订单总价=现价+运费；totalPrice：订单现价，就是折扣后的价格；oriPrice：订单原价；addressInfo：收货地址
	*/
	public final static String ORDER_ADD = URL_API_HOST+"api/order/add"+PARAMS_TOKEN;
	/**
	 * Method: POST  关闭订单
	*	@params id：订单ID；uid：用户ID
	 */
	public final static String ORDER_CLOSE = URL_API_HOST+"api/order/close"+PARAMS_TOKEN;
	
	/**
	 * 设置订单为已付款状态
	*	Method:POST
	* @params id：订单ID；
	 */
	public final static String ORDER_PAY = URL_API_HOST+"api/order/pay"+PARAMS_TOKEN;
	
	/**
	 * 设置订单为已经收货状态
	*	Method:POST
	* @params id：订单ID；
	 */
	public final static String ORDER_RECEPIT = URL_API_HOST+"api/order/checkOrder"+PARAMS_TOKEN;
	
	/**
	 * Method: GET
	*	@params id：订单ID；uid：用户ID
	 */
	public final static String ORDER_DETAIL = URL_API_HOST+"api/order/detail"+PARAMS_TOKEN;
	//public final static String ORDER_DETAIL ="http://www.etejia.cn/json_order_detail.html";
	/**
	 * Method: GET 获取未支付订单
	*	@params uid：用户ID start：起始位置，0是第一条；count：订单数量，默认20（可选）
	 */
	public final static String ORDER_UNPAID = URL_API_HOST+"api/order/unpaid"+PARAMS_TOKEN;
	
	/**
	 * Method: GET 获取已支付订单
	*	@params uid：用户ID start：起始位置，0是第一条；count：订单数量，默认20（可选）
	 */
	public final static String ORDER_PAID = URL_API_HOST+"api/order/paid"+PARAMS_TOKEN;
	//public final static String ORDER_PAID ="http://www.etejia.cn/json6.html";
	
	/**
	 * Method: GET  获取已经完成的订单，例如已经关闭、已经收货的订单
	*	@params uid：用户ID start：起始位置，0是第一条；count：订单数量，默认20（可选）
	 */
	public final static String ORDER_COMPLETE = URL_API_HOST+"api/order/complete"+PARAMS_TOKEN;
	
	/**
	 *WebView 获取商品物流信息
	*	@params uid：用户ID id:订单id
	 */
	public final static String ORDER_TRACK = URL_API_HOST+"api/order/trackView"+PARAMS_TOKEN;
	
	/**
	 * 对URL进行格式处理
	 * @param path
	 * @return
	 */
	private final static String formatURL(String path) {
		if(path.startsWith("http://") || path.startsWith("https://"))
			return path;
		return "http://" + URLEncoder.encode(path);
	}	
}
